//
//  NoBlindingWithDevice.m
//  iiecg
//
//  Created by 123456 on 2017/11/17.
//  Copyright © 2017年 Boundary Technology. All rights reserved.
//

#import "NoBlindingWithDeviceView.h"
#import "Masonry.h"
#import "UIView+Corner.h"

@interface NoBlindingWithDeviceView()

@end

@implementation NoBlindingWithDeviceView

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        [self setUpUI];
    }
    return self;
}

-(void)setUpUI
{
    UIImageView *imageView = [[UIImageView alloc] init];
    imageView.image = [UIImage imageNamed:@"ecg_blindDevice"];
    [self addSubview:imageView];
    [imageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(self);
        make.centerY.equalTo(self.mas_centerY).with.offset(-150);
        make.width.mas_equalTo(114);
        make.height.mas_equalTo(114);
    }];
    
    UILabel *label = [[UILabel alloc] init];
    label.text = INTERNATIONAL(@"string_no_bonded_device");
    label.textColor = COLOR_BLACK_6F6F6F;
    label.font = FONT_BASIC;
    label.textAlignment = NSTextAlignmentCenter;
    label.numberOfLines = 0;
    [self addSubview:label];
    [label mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(imageView.mas_bottom).with.offset(25);
        make.left.mas_equalTo(20);
        make.right.mas_equalTo(-20);
        make.height.mas_equalTo(36);
    }];
    
    UILabel *descLab = [[UILabel alloc] init];
    descLab.textColor = [UIColor lightGrayColor];
    descLab.text = INTERNATIONAL(@"string_bond2use");
    descLab.font = FONT_LABEL;
    descLab.textAlignment = NSTextAlignmentCenter;
    descLab.numberOfLines = 0;
    [self addSubview:descLab];
    [descLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(label.mas_bottom).with.offset(10);
        make.left.and.right.equalTo(label);
        make.height.mas_equalTo(34);
    }];
    
    UIButton *blindingButton = [[UIButton alloc] init];
    self.blindingButton = blindingButton;
    self.blindingButton.userInteractionEnabled = YES;
    [blindingButton setTitle:INTERNATIONAL(@"string_bonded_device") forState:UIControlStateNormal];
    [blindingButton setTitleColor:ECG_COLOR_WHITE forState:UIControlStateNormal];
    [blindingButton addTarget:self action:@selector(blinding) forControlEvents:UIControlEventTouchUpInside];
    blindingButton.titleLabel.font = FONT_BUTTON;
    blindingButton.backgroundColor = COLOR_PALETTE_LIGHT_GREEN;
    blindingButton.cornerRadius = 25;
    [self addSubview:blindingButton];
    [blindingButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(30);
        make.right.mas_equalTo(-30);
        make.top.equalTo(descLab.mas_bottom).with.offset(10);
//        make.bottom.equalTo(self.mas_bottom);
        make.height.mas_equalTo(50);
    }];
}

-(void)blinding
{
    if (self.delegate && [self.delegate respondsToSelector:@selector(callbackgoBlinding)])
    {
        [self.delegate callbackgoBlinding];
    }
}

@end

